package com.apestech.framework.xml.plugin.modul;

import com.apestech.framework.json.JSONObject;

import java.util.ArrayList;

/**
 * @author hup
 * @create 2018-12-11-16:30
 */
public class Database {
    public class DB{
        private String url;
        private String username;
        private String password;

        public DB(JSONObject json){
            this.url=json.getString("url");
            this.username=json.getString("username");
            this.password=json.getString("password");
        }

        public String getUrl() {
            return url;
        }

        public String getUsername() {
            return username;
        }

        public String getPassword() {
            return password;
        }
    }

    private JSONObject db=new JSONObject();

    public void addDB(String theme, JSONObject json){
        if(theme==null || json==null) return;
        db.put(theme, new DB(json));
    }

    public DB getDBById(String theme){
        if(db.get(theme)==null) return null;
        return (DB) db.get(theme);
    }

    public ArrayList<String> getKeylist(){
        return db.getKeylist();
    }

}
